package com.zhanggm.springboot.springbootdemo05.kafka;

import com.alibaba.fastjson.JSON;
import com.zhanggm.springboot.springbootdemo05.pojo.User;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class TestConsumer {

    @KafkaListener(topics = {"userMsg1"})
    public void listen(ConsumerRecord<String,Object> record){
        String userJsonStr = record.value().toString();
        User user = JSON.parseObject(userJsonStr, User.class);
        System.out.println(user);
    }
}
